package com.ccsoft.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class LogUtils {

    private static void print(String msg,String level,Object... args){
        if( args != null && args.length >0 ){
            String str = msg.replace("{}","%s");
            msg = String.format(str,args);
        }

        String threadName = Thread.currentThread().getName();
        String datetime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
        System.out.println(datetime + " [ " + threadName + " - " + level +" ] " + msg);
    }

    public static void info(String msg,Object... args){
        print(msg,"info",args);
    }

    public static void error(String msg,Object... args){
        print(msg,"error",args);
    }
}
